﻿using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

namespace UDS.SubModule.UnitiveDocument
{
	/// <summary>
	/// CopyTeam 的摘要说明。
	/// </summary>
    [CLSCompliant(false)]
    public partial class CopyTeamPage : Page
	{
		private string FromID = "";
		private string ToID = "";

		private void Page_Load(object sender, System.EventArgs e)
		{
			if(!Page.IsPostBack)
			{
				FromID	 = (Request.QueryString["FromID"]!=null)?Request.QueryString["FromID"].ToString():"";
				ViewState["FromID"] = FromID;

				projTreeView.UserName = SiteContext.Current.UserName;
				projTreeView.DisplayFunctionNode = false;
				projTreeView.ImagePath = "../../../DataImages/";
				projTreeView.Bind();
			}
			else
			{
				FromID = ViewState["FromID"].ToString();
			}
		}


		#region Web 窗体设计器生成的代码
		override protected void OnInit(EventArgs e)
		{
			//
			// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
			//
			InitializeComponent();
			base.OnInit(e);
		}
		
		/// <summary>
		/// 设计器支持所需的方法 - 不要使用代码编辑器修改
		/// 此方法的内容。
		/// </summary>
		private void InitializeComponent()
		{    
			this.btn_OK.Click += new System.EventHandler(this.btn_OK_Click);
			this.Load += new System.EventHandler(this.Page_Load);

		}
		#endregion


		private void btn_OK_Click(object sender, System.EventArgs e)
		{
			UDS.Components.ProjectClass project = new UDS.Components.ProjectClass();
			ToID = projTreeView.SelectedClassIndex.ToString();
			try
			{
				project.Copy(Int32.Parse(FromID),Int32.Parse(ToID),SiteContext.Current.UserName);
				Response.Write("<script>alert('复制成功');close();</script>");
			}
			catch
			{
				Response.Write("<script>alert('复制失败');</script>");
			}
			
		}
	}
}
